package lab3_2;

public class ExerciseSheet {
    
    public static void main(String[] args) {
        System.out.println("=== 设计二测试：面向对象的继承设计 ===");
        
        // (1) 产生50道加法的练习题
        System.out.println("\n1. 50道加法运算题：");
        Exercise additionExercise = new Exercise();
        additionExercise.generateAdditionExercise(50);
        additionExercise.formateAndDisplay();
        
        // (2) 产生50道减法的练习题
        System.out.println("\n2. 50道减法运算题：");
        Exercise subtractionExercise = new Exercise();
        subtractionExercise.generateSubstractExercise(50);
        subtractionExercise.formateAndDisplay();
        
        // (3) 产生50道混合运算的练习题
        System.out.println("\n3. 50道加法减法混合运算题：");
        Exercise mixedExercise = new Exercise();
        mixedExercise.generateBinaryExercise(50);
        mixedExercise.formateAndDisplay();
        
        // 测试继承和多态
        testPolymorphism();
    }
    
    public static void testPolymorphism() {
        System.out.println("\n=== 多态性测试 ===");
        
        // 使用父类引用指向子类对象
        BinaryOperation op1 = new AdditionOperation(15, 8);
        BinaryOperation op2 = new SubstractOperation(20, 5);
        
        System.out.println("加法算式: " + op1.fullString());
        System.out.println("减法算式: " + op2.fullString());
        
        // 测试静态工厂方法
        BinaryOperation op3 = BinaryOperation.generateOperation('+');
        BinaryOperation op4 = BinaryOperation.generateOperation('-');
        BinaryOperation op5 = BinaryOperation.generateBinaryOperation();
        
        System.out.println("工厂方法生成的加法: " + op3.fullString());
        System.out.println("工厂方法生成的减法: " + op4.fullString());
        System.out.println("工厂方法生成的随机算式: " + op5.fullString());
    }
}
